﻿using System;
using ApplicationBoilerplate.Logging;
using MvcForum.Hosting.Azure.Storage;

namespace MvcForum.Hosting.Azure {

	public class BlobTableLogger : ILogger {

		public void Log(EventType type, String message, Exception ex) {
			String exceptionText = String.Empty;
			if (ex != null) {
				exceptionText = String.Format("{0}{2}{1}", ex.Message, ex.StackTrace, Environment.NewLine);
			}

			new LogRepository().Create<LogEntry>(new LogEntry(type, message, exceptionText));
		}

		public void Log(EventType type, String message) {
			this.Log(type, message, null);
		}
	}
}